package com.gaggle.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@MappedSuperclass
public abstract class BaseEntity implements Serializable {

	private static final long serialVersionUID = 1L;
	private Date createdDtm;
	private Date modifiedDtm;

	@Temporal(TemporalType.DATE)
	@Column(name = "CREATED_DTM", updatable = false, insertable = false)
	@org.hibernate.annotations.Generated(org.hibernate.annotations.GenerationTime.ALWAYS)
	public Date getCreatedDtm() {
		return this.createdDtm;
	}

	public void setCreatedDtm(Date createdDtm) {
		this.createdDtm = createdDtm;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "MODIFIED_DTM", updatable = false, insertable = false)
	@org.hibernate.annotations.Generated(org.hibernate.annotations.GenerationTime.ALWAYS)
	public Date getModifiedDtm() {
		return this.modifiedDtm;
	}

	public void setModifiedDtm(Date modifiedDtm) {
		this.modifiedDtm = modifiedDtm;
	}

	// @Column(name = "soft_delete")
	// private String softDelete;
	//
	// @Version
	// @Column(name = "version")
	// private Integer version;

	// public Integer getVersion() {
	//
	// return version;
	// }

//	@PrePersist
//	public void prePersist() {
//
//		// setSoftDelete(FraudCheckConst.EXCLUDE_SOFT_DELETE);
//		setCreatedDate(new Timestamp(System.currentTimeMillis()));
//		setLastModifiedDate(new Timestamp(System.currentTimeMillis()));

		// Provide default value only if one has not been provided.
		// if (this.getCreatedBy() == null) {
		// this.setCreatedBy(FraudCheckConst.CREATE_BY);
		// }

		// Provide default value only if one has not been provided.
		// if (this.getLastModifiedBy() == null) {
		// setLastModifiedBy(FraudCheckConst.LAST_MODIFIED_BY);
		// }
//	}
//
//	@PreUpdate
//	public void preUpdate() {
//
//		setLastModifiedDate(new Timestamp(System.currentTimeMillis()));

		// Provide default value only if one has not been provided.
		// if (this.getLastModifiedBy() == null) {
		// setLastModifiedBy(FraudCheckConst.LAST_MODIFIED_BY);
		// }

//	}

	/**
	 * @PreRemove public void preRemove() throws FraudEngineSystemException {
	 * 
	 *            throw new
	 *            FraudEngineSystemException(ErrorCode.HARD_DELETE_NOT_ALLOWED);
	 *            }
	 */
	/**
	 * Check if the entity has been soft deleted
	 * 
	 * @return soft delete status
	 */
	// public boolean isDeleted() {
	//
	// return
	// FraudCheckConst.INCLUDE_SOFT_DELETE.equalsIgnoreCase(this.getSoftDelete());
	// }
}